package com.pattern.singleton;

/**
 * 单例模式
 * 饿汉模式，加载时候就分配对象
 * @author LYao15
 */
public class SingletonPattern1 {
    //声明一个对象
    public static SingletonPattern1 singleton = new SingletonPattern1();

    //构造函数私有化
    private SingletonPattern1(){
        if(singleton != null){
            throw new RuntimeException("oopration is not be allowed!");
        }
    }

    public static SingletonPattern1 getSingleton(){
        return singleton;
    }
}
